﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Timers;
using System.Runtime.InteropServices;

namespace intelliSys.UI.Interaction.MouseGesture
{
    /// <summary>
    /// To start, you must associate the window's LeftMouseDown with DragMove() to enable drag move of the window.
    /// </summary>
    public abstract class MouseGestureBase
    {
        /// <summary>
        /// Indicate whether the OnSensed event should be fired instantly if conditions are met regradless of whether mouse status
        /// </summary>
        public bool InstantFire
        {
            get
            {
                return instantFire;
            }
            set
            {
                instantFire = value;
            }
        }
        /// <summary>
        /// If the Timer component is used, the frequency of the timer event is fired
        /// </summary>
        public int SensitivityInterval
        {
            get
            {
                return sensitivity;
            }
            set
            {
                if (value <= 15)
                {
                    throw new InvalidOperationException("PARAMETER MUST BE LARGER THAN 15");
                }
                else
                {
                    sensitivity = value;
                    tmr.Interval = sensitivity;
                }
            }
        }
        /// <summary>
        /// The default Sensitivity
        /// </summary>
        int sensitivity = 140;
        /// <summary>
        /// The status. Currently this is not used.
        /// </summary>
        internal SenseState senseState = SenseState.Idle;
        /// <summary>
        /// <para>Should fire if event is delayed.</para>
        /// <para>This is used in conjunction with InstantFire</para>
        /// </summary>
        internal bool fire = false;
        private bool instantFire = false;
        /// <summary>
        /// The Window that is associated with this event
        /// </summary>
        internal Window wnd;
        /// <summary>
        /// The event is fired when conditions are met
        /// </summary>
        public abstract event EventHandler<MouseGestureEventArgBase> OnSensed;
        internal Timer tmr;
        /// <summary>
        /// The thread that is used to detect gesture
        /// </summary>
        internal System.Threading.Thread thread;
        /// <summary>
        /// Builds an instance of MouseGesture
        /// </summary>
        /// <param name="window">The Window to be associated with this gesture detector</param>
        internal MouseGestureBase(Window window)
        {
            wnd = window;
            tmr = new Timer();
        }

    }
}
